package calendar.messages;

import calendar.*;
import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;

/* this class represents a single user */
import java.util.ArrayList;
public class NotifyUser implements Message
{
  private static final long serialVersionUID = 3475759L;

  public User user;
  public ArrayList users;

  public NotifyUser()
  {
    user   = null;
    users  = null;
  }

  public User getUser()
  {
    return this.user;
  }

  public ArrayList getUsers()
  {
    return this.users;
  }

  public void marshal(BlockOutputStream stream) throws IOException
  {
    this.user.marshal(stream);
    stream.writeInt( this.users.size() );
      for (int i = 0; i < users.size(); i++)
      {
          User aUser = (User)users.get(i);
          aUser.marshal(stream);
      }
  }
  public void unmarshal(BlockInputStream stream) throws IOException
  {
    this.user = new User();
    this.user.unmarshal(stream);
    this.users = new ArrayList();
    int numUsers = stream.readInt();
      for (int i = 0; i < numUsers; i++)
      {
          User aUser = new User();
          aUser.unmarshal(stream);
          this.users.add(aUser);
      }
  }
}
